import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CollectPostsVO, CollectPostsForm, CollectPostsQuery } from '@/api/collect/collectPosts/types';

/**
 * 查询帖子收藏列表
 * @param query
 * @returns {*}
 */

export const listCollectPosts = (query?: CollectPostsQuery): AxiosPromise<CollectPostsVO[]> => {
  return request({
    url: '/collect/collectPosts/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询帖子收藏详细
 * @param collectId
 */
export const getCollectPosts = (collectId: string | number): AxiosPromise<CollectPostsVO> => {
  return request({
    url: '/collect/collectPosts/' + collectId,
    method: 'get'
  });
};

/**
 * 新增帖子收藏
 * @param data
 */
export const addCollectPosts = (data: CollectPostsForm) => {
  return request({
    url: '/collect/collectPosts',
    method: 'post',
    data: data
  });
};

/**
 * 修改帖子收藏
 * @param data
 */
export const updateCollectPosts = (data: CollectPostsForm) => {
  return request({
    url: '/collect/collectPosts',
    method: 'put',
    data: data
  });
};

/**
 * 删除帖子收藏
 * @param collectId
 */
export const delCollectPosts = (collectId: string | number | Array<string | number>) => {
  return request({
    url: '/collect/collectPosts/' + collectId,
    method: 'delete'
  });
};
